package com.song.JavaThread_day04.ch4_4;

import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;

public class FactorialCalculator implements Callable<Integer> {
	
	
	private Integer number;
	
	public FactorialCalculator(Integer number) {
		super();
		this.number = number;
	}


	public Integer call() throws Exception {
		int result =1;
		if(number ==0 || number==1)
			result =1;
		else{
			for(int i = 2; i<=number ;i++)
			{
				result *=i;
				TimeUnit.SECONDS.sleep(2);
			}
		}
		System.out.printf(" %s --- factoricalCalculator -- : %d \n", Thread.currentThread().getName(),result);
		return result;
	}

}
